function isValid(fileName, fileTypes) {
  return fileTypes.some(type => type.includes(fileName.split('.').pop()))
}

function handleFileType(commit, fileTypes) {
  // console.log(fileTypes)
  commit.files = commit.files.filter(fileInfo => isValid(fileInfo.name, fileTypes))
  // console.log('files', commit.files.map(i => i.name))
  commit.insertions = 0
  commit.deletions = 0
  commit.files.forEach(fileInfo => {
    commit.insertions += fileInfo.insertions
    commit.deletions += fileInfo.deletions
  })
  return commit
}

module.exports = handleFileType